/*
    SUSAN® - Sole of Unix Save ANything

   Copyright (C) 2003-2007 Hechzh Property
   Copyright (C) 2016-2016 Skyatlas Co. CN

   
*/
/*
 * Nic Bellamy <nic@bellamy.co.nz>, October 2003.
 *
 */
/**
 * @file
 * Process and thread timer routines, built on top of watchdogs.
 */

#ifndef BAREOS_LIB_BTIMERS_H_
#define BAREOS_LIB_BTIMERS_H_

#include "lib/timer_thread.h"
#include "lib/watchdog.h"

class BareosSocket;

struct btimer_t {
  watchdog_t* wd; /**< Parent watchdog */
  int type;
  bool killed;
  pid_t pid;             /**< process id if TYPE_CHILD */
  pthread_t tid;         /**< thread id if TYPE_PTHREAD */
  BareosSocket* bsock;   /**< Pointer to BareosSocket */
  JobControlRecord* jcr; /**< Pointer to job control record */
};

btimer_t* start_child_timer(JobControlRecord* jcr, pid_t pid, uint32_t wait);
void StopChildTimer(btimer_t* wid);
btimer_t* start_thread_timer(JobControlRecord* jcr,
                             pthread_t tid,
                             uint32_t wait);
void StopThreadTimer(btimer_t* wid);
btimer_t* StartBsockTimer(BareosSocket* bs, uint32_t wait);
void StopBsockTimer(btimer_t* wid);

#endif /* BAREOS_LIB_BTIMERS_H_ */
